package com.yysoft.admin.action;


import java.util.List;

import com.yysoft.admin.entity.Action;
import com.yysoft.admin.entity.GroupManagerQuery;
import com.yysoft.admin.service.ActionService;
import com.yysoft.web.base.BaseMainAction;

public class GroupAction extends BaseMainAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private ActionService actionService;
	private GroupManagerQuery returnObj = new GroupManagerQuery();
	
	public String tree(){
		try {
			System.out.println("------------------------------->>");
			String hql="from Action ";
			List<Action> list = actionService.find(hql);
			System.out.println(list.size());
			StringBuffer reBuffer= new StringBuffer();
			reBuffer.append("[");
			for(Action act:list){
				if(Integer.parseInt(act.getViewmode())==1){
					if(act.getPid()==0){
						reBuffer.append("{id:"+act.getActionid()+", pId:"+act.getPid()+", name:\""+act.getActionname()+"\", open:true},");
					}else if(act.getActionid()==8){
						reBuffer.append("{id:"+act.getActionid()+", pId:"+act.getPid()+", name:\""+act.getActionname()+"\", file:\""+act.getActionurl()+"\"}");
					}else{
						reBuffer.append("{id:"+act.getActionid()+", pId:"+act.getPid()+", name:\""+act.getActionname()+"\", file:\""+act.getActionurl()+"\"},");
					}
				}
				
			}
			reBuffer.append("]");
			System.out.println("--->"+reBuffer.toString());
			this.returnObj.setFlag(reBuffer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;	
	}
	
	

	public GroupManagerQuery getReturnObj() {
		return returnObj;
	}

	public void setReturnObj(GroupManagerQuery returnObj) {
		this.returnObj = returnObj;
	}

	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}

}
